# encoding:utf-8
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
from sklearn.pipeline import Pipeline
from sklearn.linear_model import LinearRegression, SGDClassifier
from sklearn.preprocessing import PolynomialFeatures, StandardScaler


x = np.arange(0, 1, 0.002) 
y = norm.rvs(0, size=500, scale=0.1) #高斯分布数据
y = y + x**2

plt.scatter(x, y, s=5)
y_test = []
y_test = np.array(y_test)

#clf = LinearRegression(fit_intercept=False)      
clf = Pipeline([('poly', PolynomialFeatures(degree=100)),
                ('linear', LinearRegression(fit_intercept=False))])  
clf.fit(x[:, np.newaxis], y)
y_test = clf.predict(x[:, np.newaxis])

plt.plot(x, y_test, linewidth=2)
plt.grid() #显示网格
plt.show()